﻿using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;

namespace Prism.WebBuilder.Processors.Base
{
	public abstract class ProcessorBase : IExecutableObject
	{
		private static ConcurrentDictionary<string, IObject> _objects = new ConcurrentDictionary<string,IObject>();

		public ProcessorArgs Args { get; set; }

		public ProcessorBase()
		{
			Args = new ProcessorArgs();
		}

		

		protected void RegisterObject(string name, IObject o)
		{
			_objects.TryAdd(name, o);
		}

		public IObject GetObject(string name)
		{
			IObject obj;
			_objects.TryGetValue(name, out obj);
			return obj;
		}

		public string  ResolvePath(string path)
		{
			if (Path.IsPathRooted(path))
				return path;
			else
			{
				return Path.Combine(Args.RootPath, path);
			}
		}
		public virtual void Process()
		{
		}

		public void Execute()
		{
			Process();
		}
	}
}
